//
//  JudgeResultCell.swift
//  LongTermInsurance
//
//  Created by DYD on 2019/1/10.
//  Copyright © 2019 HeChao. All rights reserved.
//

import UIKit

class JudgeResultCell: UITableViewCell {

    lazy var fontSize: CGFloat = 13.0
    //申请单号
    lazy var applyNumStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "申请单号："
        view.textColor = CDColor.themePink
        return view
    }()
    
    lazy var applyNumDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = UIColor.black
        view.text = ""
        return view
    }()
    
    //申请日期
    lazy var applyDateStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "申请日期："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var applyDateDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //申请人电话
    lazy var applyMobileStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "申请人电话："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var applyMobileDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //申请人居住地址
    lazy var applyAddressStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "申请人居住地址："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var applyAddressDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //监护人
    lazy var applyHelperStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "监护人："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var applyHelperDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //监护人电话
    lazy var applyHelperMobileStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "监护人电话："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var applyHelperMobileDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //评估日期
    lazy var applyResultDateStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "评估日期："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var applyResultDateDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    //评估结果
    lazy var applyResultInfoStaticLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.text = "评估结果："
        view.textColor = CDColor.grayTitleColorA
        return view
    }()
    
    lazy var applyResultInfoDetailLabel: UILabel = {
        let view = UILabel()
        view.font = UIFont.systemFont(ofSize: fontSize)
        view.numberOfLines = 2
        view.textColor = UIColor.orange//CDColor.grayTitleColorA
        view.text = ""
        return view
    }()
    
    // mainUI
    lazy var containerView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.white
        view.layer.cornerRadius = 6.0
        return view
    }()
    
    lazy var topView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.hexString(hexString: "#88C0FF")
        view.layer.cornerRadius = 6.0
        return view
    }()
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func config(model: JudgeResult) {
        applyNumDetailLabel.text = "\(model.applyNum)"
        applyDateDetailLabel.text = model.applyDate
        applyMobileDetailLabel.text = model.mobile
        applyAddressDetailLabel.text = model.address
        applyHelperDetailLabel.text = model.helperName
        applyHelperMobileDetailLabel.text = model.helperMobile
        applyResultDateDetailLabel.text = model.judgeDate
        applyResultInfoDetailLabel.text = model.judgeResult
    }
    
    func setupUI() {
        selectionStyle = .none
        let detailLeft = 120.0
        let verPadding = 15.0
        let leftGap = 20
        
        self.backgroundColor = UIColor.clear
        addSubview(containerView)
        addSubview(topView)
        
        containerView.snp.remakeConstraints { (make) in
            make.top.equalTo(20+10)
            make.left.equalTo(20)
            make.right.equalTo(-20)
            make.bottom.equalToSuperview()
        }
        
        topView.snp.remakeConstraints { (maker) in
            maker.left.equalTo(20)
            maker.right.equalTo(-20)
            maker.height.equalTo(40)
            maker.top.equalTo(10)
        }
        
        topView.addSubview(applyNumStaticLabel)
        topView.addSubview(applyNumDetailLabel)
        applyNumStaticLabel.snp.remakeConstraints { (make) in
//            make.top.equalTo(15)
            make.centerY.equalToSuperview()
            make.left.equalTo(leftGap)
        }
        applyNumDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(applyNumStaticLabel)
            make.right.equalTo(-10)
        }
        containerView.addSubview(applyDateStaticLabel)
        containerView.addSubview(applyDateDetailLabel)
        applyDateStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(20 + 15)
//            make.top.equalTo(registNumStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        applyDateDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(applyDateStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(applyMobileStaticLabel)
        containerView.addSubview(applyMobileDetailLabel)
        applyMobileStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(applyDateStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        applyMobileDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(applyMobileStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(applyAddressStaticLabel)
        containerView.addSubview(applyAddressDetailLabel)
        applyAddressStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(applyMobileStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        applyAddressDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(applyAddressStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(applyHelperStaticLabel)
        containerView.addSubview(applyHelperDetailLabel)
        applyHelperStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(applyAddressStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        applyHelperDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(applyHelperStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(applyHelperMobileStaticLabel)
        containerView.addSubview(applyHelperMobileDetailLabel)
        applyHelperMobileStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(applyHelperStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        applyHelperMobileDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(applyHelperMobileStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(applyResultDateStaticLabel)
        containerView.addSubview(applyResultDateDetailLabel)
        applyResultDateStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(applyHelperMobileStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        applyResultDateDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(applyResultDateStaticLabel)
            make.right.equalTo(-10)
        }
        
        containerView.addSubview(applyResultInfoStaticLabel)
        containerView.addSubview(applyResultInfoDetailLabel)
        
        applyResultInfoStaticLabel.snp.remakeConstraints { (make) in
            make.top.equalTo(applyResultDateStaticLabel.snp.bottom).offset(verPadding)
            make.left.equalTo(leftGap)
        }
        applyResultInfoDetailLabel.snp.remakeConstraints { (make) in
            make.left.equalTo(detailLeft)
            make.centerY.equalTo(applyResultInfoStaticLabel)
            make.right.equalTo(-10)
        }
        
    }
    
}
